import java.util.Arrays;
import java.util.Scanner;

public class Test {
    public static void display(String[] arr){
        for (int i = 0; i < arr.length; i++) {
            System.out.println("("+arr[i].length()+","+" "+"'"+arr[i]+"'"+")");
        }
    }
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        sc.nextLine();
        String[] str=new String[n];
        for (int i = 0; i < str.length; i++) {
            str[i]=sc.nextLine();
        }
       // Arrays.sort(str, (a, b) -> Integer.compare(a.length(), b.length()));
        Arrays.sort(str,(a,b)->Integer.compare(a.length(),b.length()));
       display(str);
    }
}
